<?php
if (eregi("html.php",$_SERVER['SCRIPT_NAME'])) {
    Header("Location: ../index.php");
    die();
}

class HTML {
// VARS: -
//
// METHODS:
// Begin (string, string [opt], string [opt], string [opt], string [opt], int [opt])
// End ()
// addText (string, string [opt], int [opt], int [opt], string [opt])
// addTextArea (string, string [opt], int [opt], int [opt], string [opt])
// addSubmit (string [opt], string [opt], string [opt])
// addReset (string [opt], string [opt])
// addSelect (string, array [key=>value], int [opt], int [opt], string [opt], bool [opt], string [opt], string [opt])
// addHidden (string, string [opt])
// addFile (string [opt], int [opt], int [opt])
// addMultipleFiles (string [opt], int [opt], int [opt], int[opt])
// addCheckBox (string, string [opt], string [opt])
// addPassword (stirng, string [opt], int [opt], string [opt])
// addRadio (string, string [opt], bool [opt], string [opt])
// isValid (string, string)


	// {{{ table()
    //
    // Create the <table>-tag.
    //
    // IN: string (optional) [$text: html text inside the table row]
	//     string (optional) [$width: width of the cell]
	//     int (optional) [$align: 0=left, 1=center, 2=right]
	//     int (optional) [$cellpadding: html setting]
	//     int (optional) [$cellspacing: html setting]
	//     string (optional) [$bgcolor: background color of this cell, f.e. '#24a6f7']
	//     string (optional) [$class: css style as class]
    // OUT: string [<table>-Tag]
    //
    function table($text = "", $width = "", $align = 0, $cellpadding = 0, $cellspacing = 0, $bgcolor = "", $class = "")
    {
	    $str = "<table";
		    if ($width != "") { $str.= " width='$width'"; }
		    if ($bgcolor != "") { $str.= " bgcolor='$bgcolor'"; }
			if ($class != "") { $str.= " class='$class'"; }
			    if ($align == 1) { $str.= " align='center'"; }
				elseif ($align == 2) { $str.= " align='right'"; }
		$str.=" cellpadding='$cellpadding' cellspacing='$cellspacing'>\n";
		$str.= $text;
		$str.= "</table>\n";
		
	    return $str;
    }
    // }}}


	// {{{ tr()
    //
    // Create the <tr>-tag.
    //
    // IN: string (optional) [$text: html text inside the table row]
	//     string (optional) [$valign: html setting]
	//     string (optional) [$height: html setting]
    // OUT: string [<tr>-Tag]
    //
    function tr($text = "", $valign = 0, $height = "")
    {
	    $str = "<tr";
		    if ($valign == 1) { $str.= " valign='top'"; }
			elseif ($valign == 2) { $str.= " valign='bottom'"; }
			if ($height != "") { $str.= " height='$height'"; }
		$str.= ">\n".$text."</tr>\n";
		
		return $str;
    }
    // }}}


	// {{{ td()
    //
    // Create the <td>-tag.
    //
    // IN: string (optional) [$text: html text inside the table row]
	//     int (optional) [$align: 0=left, 1=center, 2=right]
	//     string (optional) [$bgcolor: background color of this cell, f.e. '#24a6f7']
	//     string (optional) [$class: css style as class]
	//     string (optional) [$width: width of the cell]
	//     int (optional) [$colspan: html setting]
	//     int (optional) [$rowspan: html setting]
    // OUT: string [<td>-Tag]
    //
    function td($text = "", $align = 0, $bgcolor = "", $class = "", $width = "", $colspan = 0, $rowspan = 0)
    {
	    $str = "<td";
		    if ($bgcolor != "") { $str.= " bgcolor='$bgcolor'"; }
			if ($colspan != "") { $str.= " colspan='$colspan'"; }
			if ($rowspan != "") { $str.= " rowspan='$rowspan'"; }
			if ($class != "") { $str.= " class='$class'"; }
			if ($width != "") { $str.= " width='$width'"; }
			    if ($align == 1) { $str.= " align='center'"; }
				elseif ($align == 2) { $str.= " align='right'"; }
		$str.=">\n";
		$str.= $text;
		$str.= "</td>\n";
		
	    return $str;
    }
    // }}}


	// {{{ th()
    //
    // Create the <th>-tag.
    //
    // IN: string (optional) [$text: html text inside the table row]
	//     int (optional) [$align: 0=left, 1=center, 2=right]
	//     string (optional) [$bgcolor: background color of this cell, f.e. '#24a6f7']
	//     string (optional) [$class: css style as class]
	//     string (optional) [$width: width of the cell]
	//     int (optional) [$colspan: html setting]
	//     int (optional) [$rowspan: html setting]
    // OUT: string [<th>-Tag]
    //
    function th($text = "", $align = 0, $bgcolor = "", $class = "", $width = "", $colspan = 20, $rowspan = 0)
    {
	    $str = "<th";
		    if ($bgcolor != "") { $str.= " bgcolor='$bgcolor'"; }
			if ($colspan != "") { $str.= " colspan='$colspan'"; }
			if ($rowspan != "") { $str.= " rowspan='$rowspan'"; }
			if ($class != "") { $str.= " class='$class'"; }
			if ($width != "") { $str.= " width='$width'"; }
			    if ($align == 1) { $str.= " align='center'"; }
				elseif ($align == 2) { $str.= " align='right'"; }
		$str.=">\n";
		$str.= $text;
		$str.= "</th>\n";
		
	    return $str;
    }
    // }}}


	// {{{ center()
    // Create the <center>-tag.
    //
    // IN: string (optional) [$text: html text inside the tag]
	//     string (optional) [$class: css style as class]
    // OUT: string [<center>-Tag]
    //
    function center($text = "", $class = "")
    {
	    $str = "<center";
		    if ($class != "") { $str.= " class='$class'"; }
		$str.= ">";
		$str.= $text;
		$str.= "</center>\n";
		
		return $str;
    }
    // }}}


	// {{{ headline()
    // Create the headline.
    //
    // IN: string (optional) [$text: html text inside the tag]
	//     string (optional) [$class: css style as class]
    // OUT: string [headline]
    //
    function headline($text = "", $class = "")
    {
	    $str = "<h1";
		    if ($class != "") { $str.= " class='$class'"; }
		$str.= ">";
		$str.= $text;
		$str.= "</h1>\n";
		
		return $str;
    }
    // }}}


	// {{{ time2str()
    // Create the string from timestamp data.
    //
    // IN: string [$time: timestamp data]
    // OUT: string [html string]
    //
    function time2str($time)
    {
	    $str = substr($time,8,2);
		$str.= ".";
		$str.= substr($time,5,2);
		$str.= ".";
		$str.= substr($time,0,4);
		$str.= " &nbsp; ";
		$str.= substr($time,11,2);
		$str.= ":";
		$str.= substr($time,14,2);
		$str.= ":";
		$str.= substr($time,17,2);
		
		return $str;
    }
    // }}}


}
?>